package cn.com.inossem.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import cn.com.inossem.activity.R;

/**
 * Created by Mickey.Li
 * Time 2017-10-9 下午 2:14
 */

public class BankTypeAdapter extends RecyclerView.Adapter<BankTypeAdapter.BankTypeHolder> {
	private Context context;
	private View.OnClickListener listener;
	private String[] bankType = new String[]{};

	public BankTypeAdapter(Context context, View.OnClickListener listener, String[] bankType) {
		this.context = context;
		this.listener = listener;
		this.bankType = bankType;
	}

	@Override
	public BankTypeHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		BankTypeHolder bankTypeHolder = new BankTypeHolder(LayoutInflater.from(context).inflate(R.layout.item_bant_type, null));
		return bankTypeHolder;
	}

	@Override
	public void onBindViewHolder(BankTypeHolder holder, int position) {
		holder.bank.setText(bankType[position]);
		holder.bank.setTag(position);
		holder.bank.setOnClickListener(listener);
	}

	@Override
	public int getItemCount() {
		return bankType.length;
	}

	public class BankTypeHolder extends RecyclerView.ViewHolder {
		TextView bank;

		public BankTypeHolder(View itemView) {
			super(itemView);
			bank = (TextView) itemView.findViewById(R.id.bank);
		}
	}
}
